init()
{
	self endon("disconnect");
	//self endon("killed_player");
	
	if(!level.spawnprotection) { self.spawnprotected = false; return; }
		
	if(isDefined(self.protected_hud))
		self.protected_hud destroy();

	self.spawnprotected = true;
	self.protectiontime = level.spawnprotectduration;

	self.protected_hud = newClientHudElem(self);
	self.protected_hud.x = 125;
	self.protected_hud.y = 540; // Was 210
	self.protected_hud.alignX = "center";
	self.protected_hud.alignY = "bottom";
	//self.protected_hud.horzAlign = "center_safearea";
	//self.protected_hud.vertAlign = "center_safearea";
	self.protected_hud.alpha = 1;
	self.protected_hud.archived = false;
	self.protected_hud.fontscale = 1;
	self.protected_hud.color = (0.984, 0.996, 0.078);
	self.protected_hud setText(game["hud_text_protected"]);
	
	self thread hasAttacked();
		
	while(self.protectiontime)
	{
		if(!self.spawnprotected)
			break;

		self.protectiontime--;
		wait 1;
	}
		
	self.spawnprotected = false;
	
	if(isDefined(self.protected_hud))
		self.protected_hud destroy();
	
}

hasAttacked()
{
	self endon("disconnect");
	//self endon("killed_player");
	
	while(self.spawnprotected)
	{
		if(self attackButtonPressed())
			self.spawnprotected = false;
		
		wait 0.1;
	}
}